<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link rel="stylesheet" href="model.css" />


   <?php include("head.php"); ?>
 <?php include("entete.php"); ?>
   <?php include("menu.php"); ?>
<?php

try{
  $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
  $bdd = new PDO('mysql:host='.DB_SERVER.';dbname='.DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $pdo_options);
  
  //récupération de la variable d'URL,
  //qui va nous permettre de savoir quel enregistrement modifier
  $id_personne  = $_GET["idPersonne"] ;
  $id_adherent  = $_GET["idAdherent"];
  $nom  = $_GET["nomPersonne"];
  $prenom = $_GET["prenomPersonne"];
  $id_assoc = $_GET["idAssociation"];
  
  //requête SQL:
  
  $sql = 'SELECT *
            FROM ADHERENT, PERSONNE, COTISATION 
	    WHERE ADHERENT.ID_ADHERENT = '.$id_adherent.'
 AND ADHERENT.ID_ADHERENT = COTISATION.ID_ADHERENT 
AND COTISATION.ID_ASSOC = '.$id_assoc.' 
AND ADHERENT.ID_PERSONNE = PERSONNE.ID_PERSONNE';
  
  
  $reponse = $bdd->query($sql);
  
  
  
  //affichage des données:
  if( $donnees = $reponse->fetch() )
    { 
      ?>
      <form action="modif2_adherent.php" method="POST">
	<input type="hidden" name="id_adherent" value="<?php echo($id_adherent) ;?>">

	<input type="hidden" name="id_assoc" value="<?php echo($id_assoc) ;?>">
	<table border="0" align="center" cellspacing="2" cellpadding="2">   

	<td><input type="hidden" name="nom" value="<?php echo($donnees['NOM_PERSONNE']); ?>"></td>
	
	<?php echo ($donnees['NOM_PERSONNE'].' '.$donnees['PRENOM_PERSONNE']); ?>
	<input type="hidden" name="prenom" value="<?php echo($donnees['PRENOM_PERSONNE']); ?>" /><br /><br />
	   
	   <?php echo 'Filière: '; ?>
	   <select name="filiere"  value="<?php echo($donnees['FILIERE']); ?>">
	      <option value="info">Informatique</option>
	      <option value="elec">Electronique</option>
	      <option value="telecom">Telecom</option>
	      <option value="matmeca">Matmeca</option>
	      <option value="rsi">RSI</option>
	      </select>
	      
	      <?php echo 'Promo: '; ?>
	      <select name="annee"  value="<?php echo($donnees['ANNEE']); ?>">
		 <option value="2013">2013</option>
		 <option value="2012">2012</option>
		 <option value="2011">2011</option>
		 <option value="2010">2010</option>
		 <option value="2009">2009</option>
		 </select>
		 
		 <?php echo 'Login: '; ?>
		 <input type="text" name="login"  value="<?php echo($donnees['LOGIN']); ?>"/><br /><br />
		    
		    <?php echo 'Mot de passe: '; ?>
		    <input type="text" name="mdp"  value="<?php echo($donnees['MDP']); ?>" /><br /><br />
		       
		       <?php echo 'Adresse e-mail: '; ?>
		       <input type="text" name="mail"  value="<?php echo($donnees['MAIL']); ?>" /><br /><br />
			  
			  <?php echo 'A payé sa cotisation'; ?>
			  
			  <?php if($donnees['PAYE']){ ?>
	<input type="radio" name="paye" value="oui" id="oui" checked="checked" /> <label for="oui">Oui</label>
												     <input type="radio" name="paye" value="non" id="non" /> <label for="non">Non</label>																					<?php  }
      
		    elseif(!$donnees['PAYE']){ ?>
	<input type="radio" name="paye" value="1" id="oui" /> <label for="oui">Oui</label>
												     <input type="radio" name="paye" value="0" id="non" checked="checked" /> <label for="non">Non</label>
																						<?php } ?>
	
	
	<input type="submit" value="Modifier" />
	   </p>
	   </form>
	   <?php 	    
	   }
  
  
  $reponse->closeCursor();     
}


catch (Exception $e)
{
  die('Erreur : ' . $e->getMessage());
} 
?>

 <?php include("pied_de_page.php"); ?>